package com.blit.lp.tools;

import java.util.List;

import com.blit.lp.core.cache.LPCacheManager;

/**
 * LP缓存工具类
 * @author dkomj
 *
 */
public class LPCacheKit {
	
	public static final String DEFAULT_COOKIENNAME = "lp_common";
	
	public static void put(String key, Object value) {
		LPCacheManager.getCacheHelper().put(DEFAULT_COOKIENNAME, key, value);
	}
	
	public static void put(String cacheName, String key, Object value) {
		LPCacheManager.getCacheHelper().put(cacheName, key, value);
	}
	
	public static void put(String key, Object value, int expiredTime) {
		LPCacheManager.getCacheHelper().put(DEFAULT_COOKIENNAME, key, value,expiredTime);
	}
	
	public static void put(String cacheName, String key, Object value, int expiredTime) {
		LPCacheManager.getCacheHelper().put(cacheName, key, value,expiredTime);
	}
	
	public static <T> T get(String key) {
		return LPCacheManager.getCacheHelper().get(DEFAULT_COOKIENNAME, key);
	}
	
	public static <T> T get(String cacheName, String key) {
		return LPCacheManager.getCacheHelper().get(cacheName, key);
	}
	
	public static void remove(String key) {
		LPCacheManager.getCacheHelper().remove(DEFAULT_COOKIENNAME, key);
	}
	
	public static void remove(String cacheName, String key) {
		LPCacheManager.getCacheHelper().remove(cacheName, key);
	}
	
	public static void removeAll() {
		LPCacheManager.getCacheHelper().removeAll(DEFAULT_COOKIENNAME);
	}
	
	public static void removeAll(String cacheName) {
		LPCacheManager.getCacheHelper().removeAll(cacheName);
	}
	
	@SuppressWarnings("rawtypes")
	public static List getKeys() {
		return LPCacheManager.getCacheHelper().getKeys(DEFAULT_COOKIENNAME);
	}
	
	@SuppressWarnings("rawtypes")
	public static List getKeys(String cacheName) {
		return LPCacheManager.getCacheHelper().getKeys(cacheName);
	}

}
